#include<bits/stdc++.h>
using namespace std;
queue<int>q2 , q3;
int a , n , ans; 
int main(){
	freopen("blah.in" , "r" , stdin);
	freopen("blah.out" , "w" , stdout);
	cin >> a >> n;
	q2.push(a);
	q3.push(a);
	while(n--){
		ans = min(q2.front() , q3.front());
		q2.push(ans * 2 + 1);
		q3.push(ans * 3 + 1);
		if(q2.front() < q3.front()) q2.pop();
		else if(q2.front() > q3.front()) p3.pop();
		else{
			q2.pop();
			q3.pop();
		}
	}
	cout << ans << endl;
	return 0;
}
